import request from '@/utils/request'
import { getToken } from '@/utils/auth'
export default{
  // 文章列表页------------------------
  getHealthyarticleLists(page_num,page_size){
    return request({
      url:`/article/articles?pageNum=${page_num}&pageSize=${page_size}`,
      method: 'GET',
    })
  },
  getHealthyarticleList(page_num,page_size,searchObj){
    return request({
      url:`/article/find/passages/${page_num}/${page_size}`,
      method: 'POST',
      data:searchObj,
      headers: {
              'Authorization':getToken()
            }
    })
  },
  //文章删除设置
  delarticle(articleId){
    return request({
      method: 'DELETE',
		  url:'/article?articleId='+articleId+'',
      headers: {
              'Authorization':getToken()
            }
    })
  },
  //文章添加提交submit设置
  adarticle(article,context){
    return request({
      method: 'POST',
      url:`/article?context=${context}`,
      data:article
    })
  },
   //文章修改提交submit设置
   upsubmitarticle(list){
    return request({
      method: 'PUT',
      url:'/article',
      data:list
    })
  },
   //文章修改设置
   updatearticle(id){
    return request({
        method: 'GET',
        url: '/article/id?articleId=' + id,
    })
  },

  //文章详情
  reqdetailArticle (detail){
    if(detail.articleId){
      return request({url:'/article',method:'PUT',data:detail});
      }
    },

  //题目列表页
  getHealthytopicList(page_num,page_size){
    return request({
      url:`/article/choices?pageNum=${page_num}&pageSize=${page_size}`,
      method: 'GET',
      headers: {
              'Authorization':getToken()
            }
    })
  },
  //题目新增和修改
  reqAddOrUpdateTopic (Topic){
    if(Topic.choiceId){
      return request({url:'/article/choice',method:'PUT',data:Topic, headers: {
              'Authorization':getToken()
            }});
    }
    else{
      return request({url:'/article/choice',method:'POST',data:Topic, headers: {
              'Authorization':getToken()
            }});
    }
  },
  //题目删除设置
  deltopic(choiceId){
    return request({
      method: 'DELETE',
		  url: '/article/choice?choiceId=' + choiceId,
      headers: {
              'Authorization':getToken()
            }
    })
  },

  //考试列表页
  getHealthyexamLists(page_num,page_size){
    return request({
      url:`article/exams?pageNum=${page_num}&pageSize=${page_size}`,
      method: 'GET',
    })
  },
  getHealthyexamList(page_num,page_size,searchObj){
    return request({
      url:`/article/find/exams/${page_num}/${page_size}`,
      method: 'POST',
      data:searchObj,
      headers: {
              'Authorization':getToken()
            }
    })
  },

  //考试新增和修改
  reqAddOrUpdateExam (Exam){
    if(Exam.examId){
      return request({url:'/article/exam',method:'PUT',data:Exam, headers: {
              'Authorization':getToken()
            }});
    }
    else{
      return request({url:'/article/exam',method:'POST',data:Exam, headers: {
              'Authorization':getToken()
            }});
    }
  },

  //考试删除设置
  delexam(examId){
    return request({
      method: 'DELETE',
		  url: '/article/exam?examId=' + examId,
      headers: {
              'Authorization':getToken()
            }
    })
  },

  //考试详情
  infoexam(examId,page_num,page_size){
    return request({
      method: 'GET',
		  url: `/article/examChoice?examId=${examId}&pageNum=${page_num}&pageSize=${page_size}`,
    })
  },
   //批量删除文章
   batchRemoveArticle(idList){
    return request({
      url:`/article/delArticles`,
      method:'DELETE',
      data:idList,
      headers: {
              'Authorization':getToken()
            }
    })
  },
  //批量删除考试
  batchRemoveExam(idList){
    return request({
      url:`/article/delExams`,
      method:'DELETE',
      data:idList,
      headers: {
              'Authorization':getToken()
            }
    })
  },
  //批量删除题目
  batchRemoveChoice(idList){
    return request({
      url:`/article/delChoices`,
      method:'DELETE',
      data:idList,
      headers: {
              'Authorization':getToken()
            }
    })
  },
}
